increased speed of program and fixed bug