I was coding for 3 hours but i FINALLY found the most eficient way of doing this!!!