Cleaned up code for image