Implemented gray scale code