Made use of $window and got rid of unnecessary property string