Cleaning up code to function properly..