Updated with better backwards solution