refactor mypicontroller code