fixed above UFO bug and made code more readable