updated code as per ecto review