app factory, bug fixing