refactoring and added pnl