updated to syncronize between physics and animation, with cleaner code