added graphics and cleaned up code