first easy semantical analysis to check for invalid input
fixed small movement bug