REAR solved, messy code, TESTED, ACCEPTED