cleaned up js util code