fixes #8 #5 #3 

solidified code