frame detection and collision works good but the code became a monster, next step....refractoring