added exception handling
fixed wrong return value of task