Cleaned up rbt function
Cleaned up functions