Cleaned up the functions