Workig final coded implemented