using the app container instead of facades
if statements with braces and some cleanup