wrote stylistically embarassing big function