Changing check function to return boolean