Cleaned up functionality