cleaned code to run smoothly