Reverted back to working code