fixed bugs + coding errors