extracted more methods and added more tests