Refactored working with protocols