inserted classifyGravity routine from Melisa