changed ugly code