cleanup code to make it lighter and cleaner