updated to easier maintainable code