updated init function to include better context support