Re-worked logic