reworked some of the code and changed the problem at the end.