Made more robust by adding a options and functions