Refactored Code with small changes

cleaned up code and stored color on database