refactored with new API review changes and removed some code duplication
checkstyle fixes