moved gpio refresh to the end of the call
deleted duplicate calls