completed basic application logic