refactoring
catch more exceptions (patch from Valdas Rapsevicius)
refactoring
abstraction