Fixed and Cleaned code