added gravity update function