Resolved the previous bug in a better way