Split big function to several smaller