chaged some stuff for code re-usability