Cleanup and added a check