Added pesudo code