Convert adapter code to a class