this code was moved to a private method