Update gravity.js

Cleaned up and added more comments