refactoring coap app