cleaned the code (still not clean = =)