refactored partial implementation for better performance