corrected bugs; added lerping code; added helper functions