Updated with new leaner code