better way of writing this