fix bugs move checks to top and abort if wrong