Refactored and added gravity simulation