js working but ugly