some code copied from live project