Refactored rules chain of ifs, moved to map