refactored the code a bit
remove bad code