fixed code from dropbox as suggested by @seekermrm