parse function implementation