Added some improvements and removed some duplicated method calls.