overhaul

created many functions and fixed bugs